<?php

if (!defined('BASEPATH'))
	exit('No direct script access allowed');

/**
 * Init Model
 *
 */


class Featured_model extends CI_Model {

	function __construct(){
		parent::__construct();
	}
	
	public function get_city_data($cityID=0){
		if($cityID){
			//$this->db->cache_on();
			$sql="select * from city where id=$cityID limit 1";
			$row = $this->db->query($sql)->row();
			//$this->db->cache_off();
			if($row){
				return $this->db->query($sql)->row();
			}else{
				return false;
			}
				
		}
	}
	
	public function get_region_data($regionID=0){
	
		//$this->db->cache_on();
		$sql="select * from state where id=$regionID limit 1";
		$row = $this->db->query($sql)->row();
		//$this->db->cache_off();
		if($row){
			return $this->db->query($sql)->row();
		}else{
			return false;
		}
	}
	
	//--Get Category info--ypgov//
	function getCategory_info($catID){
		$sql="select * from category_tree where id=$catID limit 1";
		$query = $this->db->query($sql);
		$result = $query->row();
		if ($query->num_rows() > 0){
			return $result;
		} else {
			return false;
		}
	}
	//-- GET LISTING --TAG LINK---//
	public function getTagLink($profileID=0, $limit=99){
		$sql = "select term_value from term where listing_id = $profileID and term = 'key' limit 2, $limit";
		$result = $this->db->query($sql)->result();
		$link='';
	
		if($result){
	
			foreach ($result as $key){
				$n = $this->getCategory_info($key->term_value)->name;
				$u = base_url()."browse/practice/".$this->commoncall->url($n)."-".$key->term_value;
				$link.="<a class='text-muted' href=$u>". $n." </a>, ";
			}
				
			$length = strlen(trim($link));
			$link = substr_replace($link, '', $length - 1, $length);
			return $link;
	
		}else{
			return null;
		}
	}
	
	/*function getFeatured_deatils($featured_id=0)
	{
		$sql = "select * from post where id= $featured_id and status=51 limit 1";
		$result = $this->db->query($sql)->row();
		if($result){
			return $result;
		}else{
			return false;
		}
	}*/
}